import torch


# 创建张量
t = torch.tensor([[1,2,3],[4,5,6]])
print(t)
# TODO shape获取形状
print(t.shape,t.shape[0],t.shape[1],t.shape[-1])

# TODO reshape修改形状(元素个数不会发生变化)
print(t.reshape(3,2))

print(t.reshape(1,6))

print(t.reshape(6,1))

# print(t.reshape(2,2)) # 个数不匹配会发生报错
# print(t.reshape(3,3))


t4  = t.unsqueeze(dim = 0)
print(t4,t4.shape,t4.ndim,end= '\n')


t4  = t.squeeze(dim = 0)
print(t4,t4.shape,t4.ndim,end= '\n')
